package IO.g1;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;

public class FileTest implements FilenameFilter{

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		String sep = File.separator;
		char seperator = File.separatorChar;
		
		File absoluteDirectory = new File(sep+"Hallo"+sep+"hallo.txt");
		System.out.println(absoluteDirectory.exists());
		
		File relativeDirectory = new File("./Hallo/hallo.txt");
		System.out.println(relativeDirectory.getCanonicalPath());
		
		File f = File.createTempFile("temp", ".txt");
		System.out.println(f.getAbsolutePath());
		
		f.deleteOnExit();
		
		boolean status;
		status = new File("/temp/").mkdir();
		System.out.println(status);
		status = new File("/temp1/bla/").mkdirs();
		System.out.println(status);
		
		String[] entries = new File(".").list(new FileTest());
		System.out.println(Arrays.toString(entries));
		
	}

	@Override
	public boolean accept(File dir, String name) {
		return new File(dir,name).isFile() && 
				name.toLowerCase().endsWith(".txt");
	}

}
